package com.puny.mvc.controllers.particle
{
	import com.puny.mvc.controllers.Controller;
	import com.puny.testframework.TestCaseWithStage;
	
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class ParticleLoopControllerTest extends TestCaseWithStage
	{
		public function ParticleLoopControllerTest(methodName:String=null)
		{
			super(methodName);
		}
		
		private var _ctrl:ParticleLoopController
		private var _container:Controller;
		public function testParticle():void {
			_container = new Controller();
			_ctrl = new ParticleLoopController(new SampleWorld());
			var first:int = 5000;
			var second:int = 10000;
			var third:int = second+first;
			var timer:Timer = new Timer(first,1);
			timer.addEventListener(TimerEvent.TIMER, addAsync(firstHandler,first+1000));
			timer.start();
//			timer = new Timer(second,1);
//			timer.addEventListener(TimerEvent.TIMER, addAsync(secondHandler,second+1000));
//			timer.start();
			timer = new Timer(third,1);
			timer.addEventListener(TimerEvent.TIMER, addAsync(firstHandler,third+1000));
			timer.start();
			
			_container.addChild(_ctrl);
			mainStage.addChild(_container);
			_ctrl.x = 100;
			_ctrl.y = 100;
		}
		
		private function firstHandler(event:Event):void {
			_ctrl.complete();
			
		}
		
		private function secondHandler(event:Event):void {
			_ctrl.reset();
			_container.addChild(_ctrl);
		}
		
	}
}